/*
 *    This file is part of BlobDB.
 *
 *    BlobDB is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    BlobDB is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with BlobDB.  If not, see <http://www.gnu.org/licenses/>.
 *    
 *    Copyright(c) 2011 Michael Kankkonen
 *    http://www.vnetcon.org
 */


package org.vnetcon.blobdb.database;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

/**
 * This excepetion is trhown by BlobDB if the row id for update/delete row doesn't 
 * match with the rowid in database. (Usually because someone has updated the row
 * during you have access it in your client program ;) ).
 * 
 */
public class SQLRowIdConflictException extends Exception {

	List<String> rowColumns = new ArrayList<String>();
	Hashtable<String, String> colValues = new Hashtable<String, String>();
	int updateDateInDatabase = -1;
	int updateTimeInDatabase = -1;
	int updateMillsInDatabase = -1;
	
	public SQLRowIdConflictException(String message, List<String> cols, Hashtable<String,String> values, int date, int time, int mills){
		super(message);
		this.rowColumns = cols;
		this.colValues = values;
		this.updateDateInDatabase = date;
		this.updateTimeInDatabase = time;
		this.updateMillsInDatabase = mills;
	}

	/**
	 * This will return the row columns from database to help find differences
	 * between update/delete data and existing data in database.
	 * 
	 * @return
	 */
	public List<String> getRowColumns() {
		return rowColumns;
	}

	/**
	 * This Hashtable will contain the values in databse mapped to column values.
	 * 
	 * @return
	 */
	public Hashtable<String, String> getColValues() {
		return colValues;
	}

	/**
	 * Returns the update date the data has in database.
	 * The format for this is YYYYMMDD
	 * 
	 * @return
	 */
	public int getUpdateDateInDatabase() {
		return updateDateInDatabase;
	}

	/**
	 * Returns the update time the data has in database.
	 * The format for this id HHMM
	 * 
	 * @return
	 */
	public int getUpdateTimeInDatabase() {
		return updateTimeInDatabase;
	}

	/**
	 * Returns the millsecond part of timestamp in BlobDB database.
	 * 
	 * @return
	 */
	public int getUpdateMillsInDatabase() {
		return updateMillsInDatabase;
	}
	

	
	
}
